package cn.yshujia.transform;

import cn.yshujia.domain.entity.User;
import cn.yshujia.domain.vo.UserVO;

import java.util.Map;

/**
 * @author YShuJia
 * @create 2025/1/6
 * @description UserTransform
 */

public class UserTransform {
	
	static Map<Integer, String> map = Map.of(
			0, "保密",
			1, "男",
			-1, "女"
	);
	
	public static UserVO entity2VO(User user) {
		if (user == null) {
			return null;
		}
		UserVO userVO = new UserVO();
		userVO.setId(user.getId());
		userVO.setAvatar(user.getAvatar());
		userVO.setUsername(user.getUsername());
		userVO.setGender(map.get(user.getGender()));
		userVO.setEmail(user.getEmail());
		userVO.setExperience(user.getExperience());
		userVO.setCreateTime(user.getCreateTime());
		userVO.setStatus(user.getStatus());
		return userVO;
	}
}
